package demo1;

/**
 * @Author 12629
 * @Description：
 */
class Animal {
    protected String name;
    public int age;

    static {
        System.out.println("Animal::static{静态}");
    }
    {
        System.out.println("Animal::{实例}");
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal(String name, int age)");
    }/**/
    /*public Animal() {

    }*/

    public void eat() {
        System.out.println(this.name+" 正在吃饭！");
    }
}

//扩展 拓展
class Dog extends Animal{
    /*public Dog() {
        //super();
    }*/

    static {
        System.out.println("Dog::static{静态}");
    }
    {
        System.out.println("Dog::{实例}");
    }
    public Dog(String name,int age) {
        super(name,age);//调用父类的构造方法 帮助初始化 子类从父类继承过来的成员 并不会 生成父类对象
        System.out.println("Dog(String name,int age)");
    }

    public void bark() {
        System.out.println(this.name+ " 正在旺旺叫！");
    }
}

class Cat extends Animal{

    public Cat(String name, int age) {
        super(name, age);
        System.out.println("Cat(String name,int age)");
    }

    public void miaomiao() {
        System.out.println(this.name+" 正在喵喵叫！");
    }
}
public class Test {

    public static void main(String[] args) {
        Dog dog = new Dog("圆圆",10);
        System.out.println("================");
        Dog dog2 = new Dog("圆圆",10);
    }

    public static void main1(String[] args) {
        Dog dog = new Dog("圆圆",10);
        dog.bark();
        dog.eat();

        System.out.println("===========");

        Cat cat = new Cat("mimi",9);
        cat.miaomiao();
        cat.eat();
    }
}
